package com.itheima.string;

public class Demo1 {
    public static void main(String[] args) {
        int[] arr={2,4,5,6,7};

        String s = array2String(arr);
        System.out.println(s);

    }

    public static String array2String(int[] arr){
        if(arr==null || arr.length==0){
            return "[]";
        }

        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < arr.length; i++) {
            sb.append(arr[i]).append(i==arr.length-1?"]":",");
        }

        return sb.toString();


    }
}
